package cn.lccabc.common.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by L on 2018/4/18.
 */
public class DateUtils {

    public static int getTodayWeek(){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int week = calendar.get(Calendar.DAY_OF_WEEK)-1;
        week=week==0?7:week;
        return week;
    }

    public static int getMinute(Date startDate, Date endDate){
        long start = startDate.getTime();
        long end = endDate.getTime();
        int minute = (int) (end-start)/(1000*60);
        return (minute >= 0) ? minute : (minute * (-1));
    }

    public static Date getDate(int hour, int minute){
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, minute);
        return calendar.getTime();
    }

}
